<?php

/**
 * 
 * Enter description here ...
 * @author alang
 *
 */

class Exchange_mdl extends CI_Model
{
	
	
	public function __construct()
	{
		parent::__construct();
	}
	
	/**
	 * 列表
	 */
	
	public function get_exchange_list()
	{
		$result = $this->db->select( 'lottery.id,lottery.rnum,lottery.uid,lottery.rewardid,lottery.productid,lottery.createtime as lotterytime
									,product.productname,product.ptype,product.img
									,reward.infos,
									exchange.id as eid,exchange.exchangestate,exchange.shipdate,exchange.address,exchange.tracenumber,exchange.expressor
									,exchange.recvname,exchange.expressor,exchange.createtime,
									user.txemail,
									stock.id,stock.cardnum' )
							->from( 'cj_lottery as lottery' )
							->join( 'cj_products as product','product.id=lottery.productid' )
							->join( 'cj_reward as reward','reward.id=lottery.rewardid' )
							->join( 'cj_exchange as exchange','exchange.lotteryid=lottery.id','left' )
							->join( 'cj_users as user','user.uid=lottery.uid' )
							->join( 'cj_stock as stock','lottery.stockid = stock.id' )
							->order_by( 'lotterytime','DESC' )
							->get()->result_array();
		return $result;
	}
	
	/**
	 * 修改兑奖物流信息
	 */
	
	public function exchange_expreesor($id,$data)
	{
		$this->db->where( 'id', $id );	
		return $this->db->update( 'cj_exchange', $data );
	}
}